using System;
using Wasmtime;

using var engine = new Engine();
using var module = Module.FromTextFile(engine, "hello.wat");
using var linker = new Linker(engine);
using var store = new Store(engine);

linker.Define(
    "",
    "hello",
    Function.FromCallback(store, () => Console.WriteLine("Hello from C#, WebAssembly!"))
);

var instance = linker.Instantiate(store, module);

var run = instance.GetAction("run");
if (run is null)
{
    Console.WriteLine("error: run export is missing");
    return;
}

run();
